package com.yss.sofa.report.engine;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class VV {
	public static void main(String[] args) {
		ff();
		 File excelFile = new File("E://download//03模板.xls");
	
		excelFile = new File("E://download//1-1.简单报表.xlsx");
			Workbook workbook = null;
//		 try {
//			 workbook = WorkbookFactory.create(new FileInputStream(excelFile));
//		} catch (EncryptedDocumentException e2) {
//			// TODO Auto-generated catch block
//			e2.printStackTrace();
//		} catch (InvalidFormatException e2) {
//			// TODO Auto-generated catch block
//			e2.printStackTrace();
//		} catch (FileNotFoundException e2) {
//			// TODO Auto-generated catch block
//			e2.printStackTrace();
//		} catch (IOException e2) {
//			// TODO Auto-generated catch block
//			e2.printStackTrace();
//		}

		 
		boolean isXssWorkbook;
		try {
			InputStream in = new FileInputStream(excelFile);
			isXssWorkbook = EngineUtil.hasOOXMLHeader(in);
		
		Workbook excelStub = null;
		
		if (isXssWorkbook) {
			try {
				excelStub = new XSSFWorkbook(in);
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				in.close();
			}
		} else {
			try {
				excelStub = new HSSFWorkbook(in);
			}catch (Exception e) {
				e.printStackTrace();
			} finally {
				in.close();
			}
		} }catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

	}

	private static void ff() {
		String h = "";
		String[] ff = new String[] { "default", "3" };
		for (String f : ff) {
			if (!"default".equals(f))
				h = f;
				break;
				
		}
		System.out.println("eeeeeeeeeeeeee"+h);
	}
}
